package com.donleo.user.service.impl;

import com.donleo.user.common.CommonResult;
import com.donleo.user.model.Word;
import com.donleo.user.service.WordService;
import feign.hystrix.FallbackFactory;
import org.springframework.stereotype.Component;

/**
 *  FeignClient 调用异常工厂配置类
 *  服务降级
 *
 * @author liangd
 * @since 2021-01-12 17:40
 */
@Component
public class WordServiceFallbackFactory implements FallbackFactory<WordService> {

    @Override
    public WordService create(Throwable throwable) {
        return new WordService() {
            @Override
            public CommonResult feignFindAllWord() {
                return CommonResult.failed("连接异常");
            }

            @Override
            public CommonResult feignFindWordById(Integer id) {
                return CommonResult.failed("连接异常");
            }

            @Override
            public CommonResult feignCreateWord(Word word) {
                return CommonResult.failed("连接异常");
            }

            @Override
            public CommonResult feignUpdateWord(Word word) {
                return CommonResult.failed("连接异常");
            }

            @Override
            public CommonResult feignDeleteWordById(Integer id) {
                return CommonResult.failed("连接异常");
            }
        };
    }
}
